//提示框相关
var $$ = {};
$$.alert = function (body,btn) {
    $('#alertModal').remove();
    var html = [
        '<div id="alertModal" class="modal fade bs-example-modal-sm">',
            '<div class="modal-dialog modal-sm" style="margin-top:100px;">',
                '<div class="modal-content">',
                '<div class="modal-body">',
                    '<p>'+ body +'</p>',
                '</div>',
                '<div class="modal-footer" style="border-top: 1px solid #e5e5e5;padding-top: 8px;">',
                    '<button type="button" class="btn btn-raised btn-danger" data-dismiss="modal">'+ btn +'</button>',
                '</div>',
            '</div>',
            '</div>',
        '</div>'
    ].join('');
    $('body').append(html);
    $('#alertModal').modal();
};
$$.confirm = function (body, btnCancel, btnEnter) {
    $('#confirmModal').remove();
    var html = [
        '<div id="confirmModal" class="modal fade bs-example-modal-sm">',
            '<div class="modal-dialog modal-sm" style="margin-top:100px;">',
                '<div class="modal-content">',
                '<div class="modal-body">',
                   '<p>'+ body +'</p>',
                '</div>',
                '<div class="modal-footer" style="border-top: 1px solid #e5e5e5;padding-top: 8px;">',
                    '<button type="button" class="btn btn-raised btn-danger" data-dismiss="modal">'+ btnCancel +'</button>',
                    '<button type="button" class="btn btn-raised btn-success">'+ btnEnter +'</button>',
                '</div>',
                '</div>',
            '</div>',
        '</div>'
    ].join('');
    $('body').append(html);
    $('#confirmModal').modal();
};
$$.tips = function (body,timeout) {
    $$.tips.timer = $$.tips.timer || {};
    clearTimeout($$.tips.timer);
    $('#tipsContainer').remove();
    var htmlWidth = $('body').width();
    var containerStyle = 'position: fixed;left: 20px;bottom: 0;z-index: 99999;word-wrap: break-word;word-break: break-all;max-width:400px';
    if(htmlWidth <= 768){
        containerStyle += 'max-width:auto;width:90%;';
    }
    var html = [
        '<div id="tipsContainer" style="'+ containerStyle +'">',
        '<div class="snackbar">',
        '<span class="snackbar-content">'+ body +'</span>',
        '</div>',
        '</div>'
    ].join('');
    $("body").append(html);
    var snackbar = $('#tipsContainer .snackbar');
    setTimeout(function () {
        snackbar.addClass('snackbar-opened');
    },50);
    $$.tips.timer = setTimeout(function () {
        snackbar.removeClass('snackbar-opened');
    },timeout);
    $('#tipsContainer').on('click','.snackbar',function () {
        snackbar.removeClass('snackbar-opened');
        clearTimeout($$.tips.timer);
    })
};